package com.lorenzogao.pley.ui.presenter

import android.app.Activity
import android.content.Context
import android.support.v4.app.Fragment
import com.lorenzogao.pley.ui.BaseView

/**
 * Created by GanLanPing
 * data:2017/12/23
 * time:13:22
 * 邮箱:2508719070@qq.com
 * Description:
 */

 open class BasePresenter<M, V : BaseView> constructor() {

    protected var mModel: M? = null

    protected var mView: V? = null


    protected  var mContext: Context?=null


    constructor(m: M, v: V) : this() {
        this.mModel = m
        this.mView = v
        initContext()
    }


    private fun initContext() {

        mContext = if (mView is Fragment) {
            (mView as Fragment).activity
        } else {
            (mView as Activity?)
        }
    }

}